###
# Traccia l'errore lanciato da qualsiasi except su viste e 
# templatetags.
#
def custom404view(request, errMsg={}):
    from django.http import HttpResponse
    from django.template import loader, Context
    errTpl = loader.get_template('500.html')
    return HttpResponse(errTpl.render(Context({'errMsg':errMsg})))

def traceError(origin=None, error='', silent=False):
    from django.http import Http404
    from libs.utils.mails import mailErrorNotification
    errMsg= {'origin':origin, 'error':error}
    try:
        mailErrorNotification(errMsg)
    except: pass
    if not silent:
        raise Http404(errMsg)